class TopicHandler:
    def __init__(self):
        self.bid = ""
        self.method = ""

    def enable_handle(self, topic: str) -> bool:
        raise NotImplementedError

    def handle(self, message: dict) -> int:
        raise NotImplementedError

    def get_cur_method(self) -> str:
        return self.method

    def get_cur_bid(self) -> str:
        return self.bid

    async def handle_message(self, message: dict, topic: str) -> int:
        if not self.enable_handle(topic):
            return 1
        return await self.handle(message)

    def get_bid(self, message: dict) -> str:
        return message.get("bid", "")

    def get_method(self, message: dict) -> str:
        try:
            return message["method"]
        except KeyError:
            raise RuntimeError("method not found")

    def get_data(self, message: dict) -> dict:
        try:
            return message["data"]
        except KeyError:
            raise RuntimeError("data not found")
